package cn.paranoid.controller;

import cn.paranoid.service.AuthenticationService;
import cn.paranoid.service.GreetingService;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
/*localhost:8080/mvc/demo/login*/
@RequestMapping("demo")
public class StarterDemo {

    private static final Logger log = LogManager.getLogger(StarterDemo.class);
    @Autowired
    private GreetingService greetingService;
    @Autowired
    private AuthenticationService authenticationService;
    @RequestMapping("login")
    public String login() {
        boolean passed = authenticationService.authentication();
        if (passed) {
            log.info("authentication passed!");
            return "forward:produceMessage";
        }
        return "error";
    }
}